const db = require("../config/config");
module.exports = {
  //根据用户id，，获取该用户购物车信息
  updateMemberInfo2(req, res) {
    console.log(req.body,'req1');
    let user_name=req.body[0].user_name
    let user_id=req.body[0].user_id
    let user_email=req.body[0].user_email
    let user_newPwd=req.body[0].user_newPwd
    let user_phone=req.body[0].user_phone
    console.log(user_id,user_email,user_name,user_phone,user_newPwd);
    console.log(`UPDATE user SET user_email =${user_email} ,user_name =${user_name},user_phone =${user_phone},user_pwd=${user_newPwd} WHERE user_id = ${user_id}`)
    db.dbMysql(`UPDATE user SET user_email =? ,user_name =?,user_phone =?,user_pwd=? WHERE user_id = ?`, [user_email,user_name,user_phone,user_newPwd,user_id], function (err, data) {
        console.log(data,'data');
        // console.log(err,'err');
     for(let i=0;i<data.length;i++){
      if(data[i].user_type==1){
           data[i].user_type='管理员'
      }
      else if(data[i].user_type==2){
        data[i].user_type='成员'
      }
      else if(data[i].user_type==3){
        data[i].user_type='用户'
      }
     }

      if (data) {
        res.send({
          code: 200,
          data: data,
          msg: "角色管理查询成功",
        });
      } else {
        res.send({
          code: 500,
          msg: "服务器错误",
        });
      }
    });
  },
};
